/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-01-07
 * Time: 15:27
 */
public class test5 {
    /*
    LeetCode 28  找出字符串中第一个匹配项的下标
     */
    public int strStr(String ss, String pp) {
        int n = ss.length();
        int m = pp.length();
        char[] s = ss.toCharArray();
        char[] p = pp.toCharArray();
        for(int i=0;i<=n-m;i++){
            int a = i;
            int b = 0;
            while(b<m && s[a]==p[b]){
                a++;
                b++;
            }
            if(b==m){
                return i;
            }
        }
        return -1;
    }
}
